import json
import os.path


class OperationJson:

    @staticmethod
    def build_data(filepath):
        # 打开json文件
        with open(filepath,mode='r',encoding='utf-8') as f:
            # 读取文件,转换数据格式
            json_data = json.load(f)
        return json_data

if __name__ == '__main__':
    # print(OperationJson.build_data('../data/login_data.json'))
    # 当前脚本的绝对路径
    print(os.path.abspath(__file__))
    # 项目根目录的绝对路径
    print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    # 最终的路径
    print(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', 'login_data.json'))
    file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', 'login_data.json')
    print(OperationJson.build_data(file_path))
